package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Exibition;
import com.ruoyi.system.service.IExibitionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 展览展示Controller
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Controller
@RequestMapping("/system/exibition")
public class ExibitionController extends BaseController
{
    private String prefix = "system/exibition";

    @Autowired
    private IExibitionService exibitionService;

    @RequiresPermissions("system:exibition:view")
    @GetMapping()
    public String exibition()
    {
        return prefix + "/exibition";
    }

    /**
     * 查询展览展示列表
     */
    @RequiresPermissions("system:exibition:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Exibition exibition)
    {
        startPage();
        List<Exibition> list = exibitionService.selectExibitionList(exibition);
        return getDataTable(list);
    }

    /**
     * 导出展览展示列表
     */
    @RequiresPermissions("system:exibition:export")
    @Log(title = "展览展示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Exibition exibition)
    {
        List<Exibition> list = exibitionService.selectExibitionList(exibition);
        ExcelUtil<Exibition> util = new ExcelUtil<Exibition>(Exibition.class);
        return util.exportExcel(list, "展览展示数据");
    }

    /**
     * 新增展览展示
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存展览展示
     */
    @RequiresPermissions("system:exibition:add")
    @Log(title = "展览展示", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Exibition exibition)
    {
        return toAjax(exibitionService.insertExibition(exibition));
    }

    /**
     * 修改展览展示
     */
    @RequiresPermissions("system:exibition:edit")
    @GetMapping("/edit/{exId}")
    public String edit(@PathVariable("exId") Long exId, ModelMap mmap)
    {
        Exibition exibition = exibitionService.selectExibitionByExId(exId);
        mmap.put("exibition", exibition);
        return prefix + "/edit";
    }

    /**
     * 修改保存展览展示
     */
    @RequiresPermissions("system:exibition:edit")
    @Log(title = "展览展示", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Exibition exibition)
    {
        return toAjax(exibitionService.updateExibition(exibition));
    }

    /**
     * 删除展览展示
     */
    @RequiresPermissions("system:exibition:remove")
    @Log(title = "展览展示", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exibitionService.deleteExibitionByExIds(ids));
    }
}
